<!DOCTYPE html>
<html lang='en'>

<head>
  <meta charset='UTF-8'>
  <meta name='viewport' content='width=device-width, initial-scale=1.0'>
  <title></title>
  <script type='text/javascript' src='js/vue.js'></script>
</head>

<body>
  <div id='app'>
    <input type="text">
    <input type="text">
    <input type="text" v-focus>
    <input type="text" v-color="msg">
    <input type="text">
  </div>
  <script type='text/javascript'>
    // Vue.directive('focus', {
    //   inserted: function (el) {
    //     el.focus();
    //     console.log(el);
    //   }
    // })
    Vue.directive('color', {
      inserted: function (el, binding) {
        el.style.backgroundColor = binding.value.color;
      }
    })
    var vm = new Vue({
      el: '#app',
      data: {
        msg: {
          color: 'orange'
        }
      },
      methods: {

      },
      directives: {
        focus: {
          inserted: function (el) {
            el.focus();
          }
        }
      }
    });
  </script>
</body>

</html>